<?php

$min = isset($_REQUEST['min']) ? intval($_REQUEST['min']) : 0;
$max = isset($_REQUEST['max']) ? intval($_REQUEST['max']) : 1000000;

$xsl = <<< xslForUnicodeMathML
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xml:lang="en">

    <xsl:output method="xml" version="1.0" encoding="Windows-1251" media-type="text/xhtml"/>

    <xsl:strip-space elements="*"/>

    <xsl:template match="/">
        <table border="0" cellpadding="0" cellspacing="0" style="color: #CCCCCC; background-color: #F8F8F8; margin: 10em; font-family: 'Arial Unicode MS';">
            <xsl:apply-templates select="charlist/character[(@dec > {$min}) and (@dec &lt; {$max})]" />
        </table>
    </xsl:template>

    <xsl:template match="character">
        <!-- not(contains(@id, '-'))  @mode = 'math' and  -->
        <tr>
            <xsl:attribute name="style">
                <xsl:if test="position() mod 2">
                    <xsl:value-of select="'background-color: #F0F0F0;'" />
                </xsl:if>
                <xsl:if test="@mode = 'math'">
                    <xsl:value-of select="'color: #000000;'" />
                </xsl:if>
            </xsl:attribute>
            <xsl:attribute name="title">
                <xsl:value-of select="@id" />
            </xsl:attribute>
            <td style="width: 3em; font-size: 300%; padding-left: 1em;">
                <xsl:text disable-output-escaping="yes">&#38;#</xsl:text>
                <xsl:value-of select="@dec" />
                <xsl:text disable-output-escaping="yes">;</xsl:text>
            </td>
            <td>
                <xsl:value-of select="description" />
                <xsl:text disable-output-escaping="yes">&#160;(</xsl:text>
                <xsl:value-of select="@dec" />
                <xsl:text disable-output-escaping="yes">)</xsl:text>
            </td>
            <td style="font-style: italic;">
                <xsl:value-of select=".//desc[1]" />
            </td>
            <td>
                <xsl:value-of select="@mode" />
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>
xslForUnicodeMathML;
$xml_dom = new DOMDocument();
$xml_dom->load('unicode.xml');
$xsl_dom = new DOMDocument();
$xsl_dom->loadXML($xsl);
$xsl = new XSLTProcessor();
$xsl->importStylesheet($xsl_dom);
echo $xsl->transformToDoc($xml_dom)->saveXML();

?>
